package Acwing.数据结构;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Title: heapSort
 * @Author 贾金博
 * @Package Acwing.数据结构
 * @Date 2025/4/10 上午11:57
 * @description: 堆排序
 */
public class heapSort {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] a = new int[n + 10];
        for(int i = 1; i <= n; i ++ ) {
            a[i] = sc.nextInt();
        }

        // 开始进行排序
        Arrays.sort(a, 1, n + 1);
        for(int i = 1; i <= m; i ++ ) {
            System.out.print(a[i] + " ");
        }

    }
}
